﻿
using System.Text;
namespace GACore.Progress
{
	public class HistoryEntry
	{
		public HistoryEntry(Vector[] population)
		{
			this.population = population;
		}

		int step;
		public int Step
		{
			get { return step; }
			set { step = value; }
		}

		Vector[] population;
		public Vector[] Population
		{
			get { return population; }
			set { population = value; }
		}

		public Vector BestVector
		{
			get { return population[0]; }
		}

		public string ToShortString()
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendLine("Eintrag für Schritt " + step);
			for (int i = 0; i < population.Length; i++)
			{
				sb.Append(string.Format("Fitness {0,2}", i + 1));
				sb.Append(". Vektor: ");
				sb.AppendLine(population[i].Fitness.ToString());
			}
			return sb.ToString();
		}

		public string ToLongString()
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendLine("Eintrag für Schritt " + step);
			foreach (var vector in population)
			{
				sb.Append(vector.ToString());
				sb.AppendLine(" , Fitness: " + vector.Fitness);
			}
			return sb.ToString();
		}
	}
}
